package Tool;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MySQL_IsStaffId_Exist {

    public static boolean isIdExist(Connection conn, int ID) throws SQLException {
        //定义sql
        //查询
        String sql = "select * from staff where id = '"+ID+"'";

        //获取执行sql的对象 Stamant
        Statement stmt = conn.createStatement();

        //执行sql
        ResultSet rs = stmt.executeQuery(sql);
        //处理结果
        if (rs.next()){
            //释放资源
            rs.close();
            stmt.close();
            //如果存在 返回 true
            return true;
        }else {
            //释放资源
            rs.close();
            stmt.close();
            //如果不存在 返回 false
            return false;
            }
    }
}
